﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace Mani.Common
{
    public class SmtpHelper
    {
        private SmtpClient client = new SmtpClient();

        public SmtpHelper(string smtpHost)
        {
            client.Host = smtpHost;
        }

        public void SendMessage(string subject, string from, string to, string cc, string bcc, string body)
        {
            MailMessage message = new MailMessage();

            string[] toAddresses = to.Split(',');
            string[] ccAddresses = cc.Split(',');
            string[] bccAddresses = bcc.Split(',');

            foreach (string t in toAddresses)
                message.To.Add(t);

            foreach (string c in ccAddresses)
                message.CC.Add(c);

            foreach (string b in bccAddresses)
                message.Bcc.Add(b);

            message.Subject = subject;
            message.Body = body;

            client.Send(message);
        }
    }
}
